home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / rcs / eroll.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  19.8 KB  |  721 lines

  1. head    1.3;
  2. access;
  3. symbols;
  4. locks
  5.     dlorre:1.3; strict;
  6. comment    @// @;
  7.  
  8.  
  9. 1.3
  10. date    97.09.17.08.15.27;    author dlorre;    state Exp;
  11. branches;
  12. next    1.2;
  13.  
  14. 1.2
  15. date    97.07.14.04.19.51;    author dlorre;    state Exp;
  16. branches;
  17. next    1.1;
  18.  
  19. 1.1
  20. date    96.08.22.02.05.10;    author dlorre;    state Exp;
  21. branches;
  22. next    ;
  23.  
  24.  
  25. desc
  26. @Oui.lib -- Object User Interface
  27. Projet créé en 1994
  28. Auteur: Dominique Lorre
  29. @
  30.  
  31.  
  32. 1.3
  33. log
  34. @*** empty log message ***
  35. @
  36. text
  37. @// $Id: eroll.cc 1.2 1997/07/14 04:19:51 dlorre Exp dlorre $
  38. #include <graphics/gfxmacros.h>
  39. #include <intuition/classes.h>
  40. #include <intuition/classusr.h>
  41. #include <intuition/gadgetclass.h>
  42. #include <intuition/cghooks.h>
  43. #include <intuition/icclass.h>
  44. #include <utility/tagitem.h>
  45. #include <utility/hooks.h>
  46. #include <libraries/gadtools.h>
  47.  
  48. #include <stdio.h>
  49. #include <mydebug.h>
  50. #include <string.h>
  51. #include <math.h>
  52. #if defined( __SASC__ )
  53. #ifdef _IEEE
  54. #include <mieeedoub.h>
  55. #endif
  56. #ifdef _M68881
  57. #include <m68881.h>
  58. #endif
  59. #endif
  60.  
  61. #include "gadgets/eroll.h"
  62. #include "gadgets/eclass.h"
  63. #include "gadgetlist.h"
  64. #include "window.h"
  65. #include "screen.h"
  66.  
  67. #include <proto/dos.h>
  68. #include <proto/graphics.h>
  69. #include <proto/intuition.h>
  70. #include <proto/utility.h>
  71. #include <clib/alib_protos.h>
  72. #include <compiler.h>
  73.  
  74. static Class *BOOPSIeroll ;
  75. static int InitERoll(void) ;
  76. static void FreeERoll(void) ;
  77.  
  78. #if !defined( PI )
  79. #define PI  3.14159265358979323846
  80. #endif
  81.  
  82. const double cPID4  = PI / 4.0  ;
  83. const double cPID2  = PI / 2.0  ;
  84. const double c3PID2  = 3.0 * PI / 2.0 ;
  85. const double c5PID4  = 5.0 * PI / 4.0 ;
  86. const double c7PID4  = 7.0 * PI / 4.0 ;
  87. const double c2PI   = 2.0 * PI ;
  88.  
  89. extern "C" STDARGS ULONG HookEntry() ;
  90.  
  91. // ========================================================================
  92. // ============================  EROLL CLASS =============================
  93. // ========================================================================
  94.  
  95.  
  96. eroll::eroll(gadgetlist *gl,
  97.                void (window::*func)(gadget *, unsigned long, unsigned short),
  98.                long min,
  99.                long max,
  100.                long level,
  101.                BOOL full) : gadget(gl, func),
  102.                             cursel(level), rmin(min), rmax(max), rfull(full)
  103. {
  104.  
  105.     InitERoll() ;
  106.  
  107.     gad = gl->gad  = (Gadget *)NewObject(BOOPSIeroll, NULL,
  108.  
  109.             GA_ID,              gl->ng->ng_GadgetID,
  110.             GA_Top,             gl->ng->ng_TopEdge,
  111.             GA_Left,            gl->ng->ng_LeftEdge,
  112.             GA_Width,           gl->ng->ng_Width,
  113.             GA_Height,          gl->ng->ng_Height,
  114.  
  115.             GA_Previous,        gl->gad,
  116.  
  117.             GA_Immediate,       TRUE,
  118.             GA_FollowMouse,     TRUE,
  119.             GA_RelVerify,       TRUE,
  120.  
  121.             GA_UserData,        EGA_Level,
  122.  
  123.             ICA_TARGET,         ICTARGET_IDCMP,
  124.  
  125.             EGA_Min,             min,
  126.             EGA_Max,             max,
  127.             EGA_Level,           level,
  128.             EGA_Full,            full,
  129.             EGA_XPens,           gl->win->ws->xpens,
  130.  
  131.             TAG_DONE);
  132. }
  133.  
  134. eroll::~eroll()
  135. {
  136.     DisposeObject(gad) ;
  137.     FreeERoll() ;
  138. }
  139.  
  140. void eroll::set(long level, long min, long max, short disable)
  141. {
  142.     SetGadgetAttrs(gad, w, NULL,
  143.         (level != -1)?EGA_Level:TAG_IGNORE,  level,
  144.         (min != -1)?EGA_Min:TAG_IGNORE,      min,
  145.         (max != -1)?EGA_Max:TAG_IGNORE,      max,
  146.         GA_Disabled,                        disable,
  147.         TAG_END) ;
  148. }
  149.  
  150. void eroll::action(unsigned long classe, unsigned short code)
  151. {
  152.     cursel = code ;
  153.     gadget::action(classe, code) ;
  154. }
  155.  
  156. void eroll::keystroke(BOOL shifted)
  157. {
  158.     if (shifted) {
  159.         cursel-- ;
  160.         if (cursel < rmin)
  161.             cursel = rfull?rmax:rmin ;
  162.     }
  163.     else {
  164.         cursel++ ;
  165.         if (cursel > rmax)
  166.             cursel = rfull?rmin:rmax ;
  167.     }
  168.     set(cursel) ;
  169.     gadget::action(NULL, cursel) ;
  170. }
  171.  
  172.  
  173. // ========================================================================
  174. // =============================== EROLL =================================
  175. // ========================================================================
  176.  
  177. struct RollINST {
  178.     BOOL        Full ;                  // Full display : 360° angle
  179.     BOOL        KnobHit ;
  180.     BOOL        RedrawAll ;
  181.  
  182.     WORD        Direction ;
  183.     long        GLeft ;                 // Coordonnées du gadget
  184.     long        GTop ;
  185.     long        GWidth ;
  186.     long        GHeight ;               // Coordonnées du gadget
  187.     long        XRadius, YRadius ;      // Rayons
  188.     long        CLeft, CTop ;           // Coordonnées du centre
  189.     long        CWidth, CHeight ;
  190.     long        KLeft, KTop ;           // Coordonnées du curseur
  191.     long        KRight, KBottom ;
  192.     long        KCenterX, KCenterY ;
  193.     double       KStart ;
  194.     long        XStartPos, YStartPos ;
  195.     long        Total, Top ;
  196.     long        Min, Max, Level ;
  197.     long        DTop, PTop ;
  198.     long        XUnity, YUnity ;
  199.     double      angPhase ;
  200.     double      angWidth ;
  201.     double      angMin ;
  202.     double      Ratio ;
  203.     UWORD       *XPens ;
  204. } ;
  205.  
  206. static ULONG STDARGS dispatchERoll(Class *cl, Object *o, Msg msg);
  207.  
  208. static void     NotifyRoll(Class *, Object *, ULONG, long, gpInput *) ;
  209.  
  210. static ULONG    RenderERoll(Class *, Gadget *, gpRender *) ;
  211.  
  212. static void     RollSize(RollINST *inst, Gadget *g) ;
  213. static void     RollLims(RollINST *inst) ;
  214.  
  215. static unsigned short ditherData[2] = {0x5555,0xAAAA};
  216. static int ERollCnt = 0 ;
  217. int InitERoll(void)
  218. {
  219.     if (ERollCnt) {
  220.         ERollCnt++ ;
  221.     }
  222.     else if (!(BOOPSIeroll = MakeClass(NULL, (UBYTE *)"propgclass", NULL,
  223.         sizeof(RollINST), 0))) {
  224.         ERollCnt = 0 ;
  225.     }
  226.     else {
  227.         BOOPSIeroll->cl_Dispatcher.h_Entry = (HOOKFUNC)HookEntry ;
  228.         BOOPSIeroll->cl_Dispatcher.h_SubEntry = (HOOKFUNC)dispatchERoll;
  229.         BOOPSIeroll->cl_Dispatcher.h_Data = NULL ;
  230.         ERollCnt = 1 ;
  231.     }
  232.     return ERollCnt ;
  233. }
  234.  
  235. void FreeERoll(void)
  236. {
  237.     ERollCnt-- ;
  238.     if (!ERollCnt)
  239.         FreeClass(BOOPSIeroll) ;
  240. }
  241.  
  242. ULONG SAVEDS STDARGS dispatchERoll(Class *cl, Object *o, Msg msg)
  243. {
  244. RollINST *inst ;
  245. ULONG retval = FALSE ;
  246. Object *object ;
  247.  
  248.     GETA4 ;
  249.     switch (msg->MethodID) {
  250.     case OM_NEW:
  251.         if (object = (Object *)DoSuperMethodA(cl, o, msg)) {
  252.             inst = (RollINST *)INST_DATA(cl, object) ;
  253.             inst->KnobHit = FALSE ;
  254.             inst->Min = (long)GetTagData(EGA_Min, 1, ((opSet *)msg)->ops_AttrList) ;
  255.             inst->Max = (long)GetTagData(EGA_Max, 16, ((opSet *)msg)->ops_AttrList) ;
  256.             inst->Full = (long)GetTagData(EGA_Full, FALSE, ((opSet *)msg)->ops_AttrList) ;
  257.             inst->Level = (long)GetTagData(EGA_Level, 1, ((opSet *)msg)->ops_AttrList) ;
  258.             inst->XPens = (UWORD *)GetTagData(EGA_XPens, NULL, ((opSet *)msg)->ops_AttrList) ;
  259.             inst->Total = inst->Max - inst->Min + 1 ;
  260.             inst->Top = inst->Level - inst->Min ;
  261.             inst->RedrawAll = TRUE ;
  262.             RollSize(inst, (Gadget *)object) ;
  263.             retval = (ULONG)object ;
  264.         }
  265.         break ;
  266.     case OM_DISPOSE:
  267.         retval = DoSuperMethodA(cl, o, msg) ;
  268.         break ;
  269.     case GM_HITTEST:
  270.         retval = DoSuperMethodA(cl, o, msg) ;
  271.         break ;
  272.     case GM_GOACTIVE:
  273.         {
  274.         gpInput *gpi = (gpInput *)msg ;
  275.         double   alpha, xp, yp, diff ;
  276.  
  277.             inst = (RollINST *)INST_DATA(cl, o) ;
  278.             if (gpi->gpi_IEvent) {
  279.                 ((Gadget *)o)->Flags |= GFLG_SELECTED ;
  280.                 inst->RedrawAll = FALSE ;
  281.  
  282.                 xp = double(gpi->gpi_Mouse.X - inst->XRadius) ;
  283.                 yp = double(inst->YRadius - gpi->gpi_Mouse.Y) * inst->Ratio ;
  284.  
  285.                 if (!xp) {
  286.                     alpha = cPID2 ;
  287.                     if (yp < 0)
  288.                         alpha = -alpha ;  // -PI/2 out of lims
  289.                 }
  290.                 else
  291.                     alpha = atan2(yp, xp) ;
  292.  
  293.                 alpha += cPID4 ;
  294.                 if (alpha < 0) alpha += c2PI ;
  295.                 diff = fabs(alpha -c2PI) ;
  296.                 if (diff < 0.00001) alpha = 0 ;
  297.  
  298.                 if (alpha <= inst->angMin)
  299.                     inst->Top =  long((inst->Total * (inst->angWidth - alpha))
  300.                         / inst->angWidth) ;
  301.  
  302.                 retval = GMR_MEACTIVE ;
  303.                 RenderERoll(cl, (Gadget *)o, (gpRender *)msg) ;
  304.                 *(gpi->gpi_Termination) = inst->Level ;
  305.                 NotifyRoll(cl, o, OPUF_INTERIM, inst->Level, gpi) ;
  306.         }
  307.         else
  308.             retval = GMR_NOREUSE ;
  309.         }
  310.         break ;
  311.     case GM_RENDER:
  312.         retval = RenderERoll(cl, (Gadget *)o, (gpRender *)msg) ;
  313.         break ;
  314.     case GM_HANDLEINPUT:
  315.         {
  316.             gpInput *gpi = (gpInput *)msg ;
  317.             InputEvent *ie = gpi->gpi_IEvent ;
  318.  
  319.             inst = (RollINST *)INST_DATA(cl, o) ;
  320.             inst->PTop = inst->Top ;
  321.             inst->RedrawAll = FALSE ;
  322.             retval = GMR_MEACTIVE ;
  323.  
  324.             if (ie->ie_Class == IECLASS_RAWMOUSE) {
  325.                 switch (ie->ie_Code) {
  326.                     case SELECTUP:
  327.                         *(gpi->gpi_Termination) = inst->Level ;
  328.                         retval = GMR_NOREUSE | GMR_VERIFY ;
  329.                         NotifyRoll(cl, o, 0, inst->Level, (gpInput *)msg) ;
  330.                         break ;
  331.                     case MENUDOWN:
  332.                         retval = GMR_REUSE ;
  333.                         NotifyRoll(cl, o, 0, inst->Level, (gpInput *)msg) ;
  334.                         break ;
  335.                     case IECODE_NOBUTTON:
  336.                         *(gpi->gpi_Termination) = inst->Level ;
  337.                         ie->ie_Code = inst->Level ;
  338.                         retval = GMR_MEACTIVE  ;
  339.                         NotifyRoll(cl, o, OPUF_INTERIM, inst->Level, gpi) ;
  340.                         break ;
  341.                 }
  342.             }
  343.             else if (ie->ie_Class == IECLASS_TIMER) {
  344.             double   alpha, xp, yp, diff ;
  345.                 xp = double(gpi->gpi_Mouse.X - inst->XRadius) ;
  346.                 yp = double(inst->YRadius - gpi->gpi_Mouse.Y) * inst->Ratio ;
  347.  
  348.                 if (!xp) {
  349.                     alpha = cPID2 ;
  350.                     if (yp < 0)
  351.                         alpha = - alpha ;
  352.                 }
  353.                 else
  354.                     alpha = atan2(yp, xp) ;
  355.  
  356.  
  357.                 alpha += cPID4 ;
  358.                 if (alpha < 0) alpha += c2PI ;
  359.                 diff = fabs(alpha -c2PI) ;
  360.                 if (diff < 0.00001) alpha = 0 ;
  361.  
  362.                 if (alpha <= inst->angMin)
  363.                     inst->Top =  long((inst->Total * (inst->angWidth - alpha))
  364.                         / inst->angWidth) ;
  365.  
  366.                 if (inst->PTop != inst->Top) {
  367.                     RenderERoll(cl, (Gadget *)o, (gpRender *)msg) ;
  368.                     NotifyRoll(cl, o, OPUF_INTERIM, inst->Level, gpi) ;
  369.                 }
  370.             }
  371.         }
  372.         break ;
  373.     case GM_GOINACTIVE:
  374.         ((Gadget *)o)-> Flags &= ~GFLG_SELECTED ;
  375.         inst = (RollINST *)INST_DATA(cl, o) ;
  376.         inst->KnobHit = FALSE ;
  377.         inst->RedrawAll = TRUE ;
  378.         RenderERoll(cl, (Gadget *)o, (gpRender *)msg) ;
  379.         break ;
  380.     case OM_GET:
  381.         {
  382.         ULONG *store = ((opGet *)msg)->opg_Storage ;
  383.  
  384.             inst = (RollINST *)INST_DATA(cl, o) ;
  385.             switch (((opGet *)msg)->opg_AttrID) {
  386.             case EGA_Min:
  387.                 *store = retval = inst->Min ;
  388.                 break ;
  389.             case EGA_Max:
  390.                 *store = retval = inst->Max ;
  391.                 break ;
  392.             case EGA_Level:
  393.                 *store = retval = inst->Level ;
  394.                 break ;
  395.             default:
  396.                 retval = DoSuperMethodA(cl, o, msg) ;
  397.             }
  398.         }
  399.         break ;
  400.     case OM_SET:
  401.         retval = DoSuperMethodA(cl, o, msg) ;
  402.         if ( FindTagItem(EGA_Min, ((opSet *)msg)->ops_AttrList) ||
  403.             FindTagItem(EGA_Max, ((opSet *)msg)->ops_AttrList) ||
  404.             FindTagItem(EGA_Level, ((opSet *)msg)->ops_AttrList) ) {
  405.             RastPort *rp ;
  406.             Gadget *g  = (Gadget *)o ;
  407.  
  408.             inst = (RollINST *)INST_DATA(cl, o) ;
  409.             inst->Min = (long)GetTagData(EGA_Min, inst->Min, ((opSet *)msg)->ops_AttrList) ;
  410.             inst->Max = (long)GetTagData(EGA_Max, inst->Max, ((opSet *)msg)->ops_AttrList) ;
  411.             inst->Level = (long)GetTagData(EGA_Level, inst->Level, ((opSet *)msg)->ops_AttrList) ;
  412.             inst->Total = inst->Max - inst->Min + 1 ;
  413.             inst->Top = inst->Level - inst->Min ;
  414.  
  415.  
  416.             if (rp = ObtainGIRPort( ((opSet *)msg)->ops_GInfo) ) {
  417.                 inst->RedrawAll = FALSE ;
  418.                 DoMethod(o, GM_RENDER, ((opSet *)msg)->ops_GInfo, rp, GREDRAW_REDRAW) ;
  419.                 ReleaseGIRPort(rp) ;
  420.                 inst->RedrawAll = TRUE ;
  421.             }
  422.         }
  423.         else
  424.             retval = DoSuperMethodA(cl, o, msg) ;
  425.         break ;
  426.     default :
  427.         retval = DoSuperMethodA(cl, o, msg) ;
  428.         break ;
  429.     }
  430.     return retval ;
  431. }
  432.  
  433.  
  434. void SAVEDS NotifyRoll(Class *cl, Object *o, ULONG flags, long level, gpInput *gpi)
  435. {
  436. static TagItem tt[3] ;
  437.  
  438.     GETA4 ;
  439.     tt[0].ti_Tag = EGA_Level ;
  440.     tt[0].ti_Data = level  ;
  441.  
  442.     tt[1].ti_Tag = GA_ID ;
  443.     tt[1].ti_Data = ((Gadget *)o)->GadgetID ;
  444.  
  445.     tt[2].ti_Tag = TAG_DONE ;
  446.  
  447.     DoSuperMethod(cl, o, OM_NOTIFY, tt, gpi->gpi_GInfo, flags) ;
  448. }
  449.  
  450. ULONG SAVEDS RenderERoll(Class *cl, Gadget *g, gpRender *msg)
  451. {
  452. RastPort    *rp ;
  453. ULONG       retval = TRUE ;
  454. UWORD       *pens = msg->gpr_GInfo->gi_DrInfo->dri_Pens ;
  455. RollINST    *inst = (RollINST *)INST_DATA(cl, (Object *)g) ;
  456. WORD        shine, shadow ;
  457.  
  458.     GETA4 ;
  459.     if (msg->MethodID == GM_RENDER)
  460.         rp = msg->gpr_RPort ;
  461.     else
  462.         rp = ObtainGIRPort(msg->gpr_GInfo) ;
  463.  
  464.     if (rp) {
  465.         shine = (g->Flags & GFLG_SELECTED)?pens[SHINEPEN]:pens[SHADOWPEN] ;
  466.         shadow = (g->Flags & GFLG_SELECTED)?pens[SHADOWPEN]:pens[SHINEPEN] ;
  467.         SetDrMd(rp, JAM1) ;
  468.  
  469.         if (g->Flags & GFLG_DISABLED) {
  470.             EraseRect(rp,
  471.                 inst->GLeft,
  472.                 inst->GTop,
  473.                 inst->GLeft+inst->GWidth,
  474.                 inst->GTop+inst->GHeight) ;
  475.         }
  476.         else {
  477.             if (!inst->RedrawAll) {
  478.                 EraseRect(rp, inst->KLeft-2, inst->KTop-2, inst->KRight+1, inst->KBottom+1) ;
  479.             }
  480.             RollLims(inst) ;
  481.             if (inst->RedrawAll) {
  482.                 EraseRect(rp,
  483.                     inst->GLeft,
  484.                     inst->GTop,
  485.                     inst->GLeft+inst->GWidth,
  486.                     inst->GTop+inst->GHeight) ;
  487.                 SetAPen(rp, pens[SHINEPEN]) ;
  488.                 DrawEllipse(rp, inst->CLeft, inst->CTop, inst->XRadius, inst->YRadius) ;
  489.                 SetAPen(rp, pens[SHADOWPEN]) ;
  490.                 DrawEllipse(rp, inst->CLeft-1, inst->CTop-1, inst->XRadius, inst->YRadius) ;
  491.             }
  492.             SetAPen(rp, shine) ;
  493.             DrawEllipse(rp, inst->KCenterX, inst->KCenterY, inst->XUnity, inst->YUnity) ;
  494.             SetAPen(rp, shadow) ;
  495.             DrawEllipse(rp, inst->KCenterX-1, inst->KCenterY-1, inst->XUnity, inst->YUnity) ;
  496.         }
  497.         if (msg->MethodID != GM_RENDER)
  498.             ReleaseGIRPort(rp) ;
  499.     }
  500.     else
  501.         retval = FALSE ;
  502.     return retval ;
  503. }
  504.  
  505. void SAVEDS RollSize(RollINST *inst, Gadget *g)
  506. {
  507. int     i ;
  508.  
  509.     GETA4 ;
  510.     inst->GLeft = g->LeftEdge ;
  511.     inst->GTop = g->TopEdge ;
  512.  
  513.     inst->CWidth = inst->GWidth = g->Width  ;
  514.     inst->CHeight = inst->GHeight = g->Height ;
  515.     inst->CWidth -= 2 ;
  516.     inst->CHeight -= 2 ;
  517.  
  518.     inst->XRadius = inst->CWidth/2 ;
  519.     inst->YRadius = inst->CHeight/2 ;
  520.     inst->Ratio = g->Width / g->Height ;
  521.  
  522.     inst->CLeft = inst->GLeft + inst->XRadius ;
  523.     inst->CTop = inst->GTop + inst->YRadius ;
  524.  
  525.     if (inst->CWidth > inst->CHeight) {
  526.         inst->YUnity = 1 ;
  527.         inst->XUnity = inst->CWidth / inst->CHeight ;
  528.     }
  529.     else {
  530.         inst->XUnity = 1 ;
  531.         inst->YUnity = inst->CHeight / inst->CWidth ;
  532.     }
  533.     inst->angPhase = c5PID4 ;
  534.     inst->angMin = c3PID2 ;
  535.     if (inst->Full) {
  536.         inst->angWidth = c2PI ;
  537.     }
  538.     else {
  539.         inst->angWidth = c3PID2 ;
  540.     }
  541.  
  542.     RollLims(inst) ;
  543. }
  544.  
  545. void SAVEDS RollLims(RollINST *inst)
  546. {
  547.     GETA4 ;
  548.     if (inst->Top < 0)
  549.         inst->Top = 0 ;
  550.     else if (inst->Top >= inst->Total)
  551.         inst->Top = inst->Total - 1 ;
  552.     inst->Level = inst->Top + inst->Min ;
  553.  
  554.     if (inst->Total)
  555.         inst->KStart = inst->angPhase -
  556.             (inst->Top * inst->angWidth) / inst->Total ;
  557.     else
  558.         inst->KStart = inst->angPhase ;
  559.  
  560.     inst->KCenterX = inst->CLeft +
  561.         long( cos(inst->KStart) * (inst->XRadius - (inst->XUnity * 3.0)) + .5) ;
  562.  
  563.     inst->KCenterY = inst->CTop -
  564.         long( sin(inst->KStart) * (inst->YRadius - (inst->YUnity * 3.0)) + .5) ;
  565.  
  566.     inst->KLeft = inst->KCenterX - inst->XUnity + 1 ;
  567.     inst->KRight = inst->KCenterX + inst->XUnity - 1 ;
  568.     inst->KTop = inst->KCenterY - inst->YUnity + 1 ;
  569.     inst->KBottom = inst->KCenterY + inst->YUnity - 1 ;
  570. }
  571.  
  572.  
  573.  
  574. @
  575.  
  576.  
  577. 1.2
  578. log
  579. @*** empty log message ***
  580. @
  581. text
  582. @d1 1
  583. a1 1
  584. // $Id$
  585. d17 1
  586. d19 4
  587. @
  588.  
  589.  
  590. 1.1
  591. log
  592. @Initial revision
  593. @
  594. text
  595. @d1 1
  596. d13 1
  597. d16 1
  598. d18 1
  599. d26 6
  600. a31 19
  601. #include <cxxproto/dos.h>
  602. #include <cxxproto/graphics.h>
  603. #include <cxxproto/intuition.h>
  604.  
  605. extern "C"
  606. {
  607. extern struct Library *UtilityBase ;
  608. struct TagItem *FindTagItem( Tag tagVal, struct TagItem *tagList );
  609. ULONG GetTagData( Tag tagValue, unsigned long defaultVal,
  610.         struct TagItem *tagList );
  611. #include <pragmas/utility_pragmas.h>
  612.  
  613. ULONG DoMethod( Object *obj, unsigned long MethodID, ... );
  614. ULONG DoSuperMethodA( struct IClass *cl, Object *obj, Msg message );
  615. ULONG DoSuperMethod( struct IClass *cl, Object *obj, unsigned long MethodID,
  616.         ... );
  617. void kprintf(STRPTR format, ...) ;
  618. }
  619.  
  620. d37 12
  621. a48 4
  622. const double c2PI   = 2*PI ;
  623. const double c3PID2  = 3*PID2 ;
  624. const double c5PID4  = 5*PID4 ;
  625. const double c7PID4  = 7*PID4 ;
  626. d161 1
  627. a161 1
  628.     double      angMax ;
  629. d165 1
  630. a165 2
  631. static ULONG __asm dispatchERoll(register __a0 Class *cl,
  632.     register __a2 Object *o, register __a1 Msg msg);
  633. d181 1
  634. a181 1
  635.     else if (!(BOOPSIeroll = MakeClass(NULL, "propgclass", NULL,
  636. d186 3
  637. a188 1
  638.         BOOPSIeroll->cl_Dispatcher.h_Entry = (HOOKFUNC)dispatchERoll;
  639. d201 1
  640. a201 3
  641. ULONG __saveds __asm dispatchERoll(register __a0 Class *cl,
  642.                            register __a2 Object *o,
  643.                            register __a1 Msg msg)
  644. d207 1
  645. d234 1
  646. a234 1
  647.         double   alpha, xp, yp ;
  648. d241 2
  649. a242 2
  650.                 xp = flt(gpi->gpi_Mouse.X - inst->XRadius) ;
  651.                 yp = flt(inst->YRadius - gpi->gpi_Mouse.Y) ;
  652. d245 1
  653. a245 1
  654.                     alpha = PID2 ;
  655. d251 9
  656. a259 6
  657.                 if (xp < 0) {
  658.                     alpha += PI ;
  659.                 }
  660.                 if (alpha <= inst->angMin || alpha >= inst->angMax)
  661.                     inst->Top =  (inst->Total * (inst->angPhase - alpha))
  662.                         / inst->angWidth ;
  663. d303 3
  664. a305 3
  665.             double   alpha, xp, yp ;
  666.                 xp = flt(gpi->gpi_Mouse.X - inst->XRadius) ;
  667.                 yp = flt(inst->YRadius - gpi->gpi_Mouse.Y) ;
  668. d308 1
  669. a308 1
  670.                     alpha = PID2 ;
  671. a313 4
  672.                 if (xp < 0) {
  673.                     alpha += PI ;
  674.                 }
  675.                 if (alpha <= inst->angMin || alpha >= inst->angMax)
  676. d315 9
  677. a323 2
  678.                     inst->Top =  (inst->Total * (inst->angPhase - alpha))
  679.                         / inst->angWidth ;
  680. d393 1
  681. a393 1
  682. void __saveds NotifyRoll(Class *cl, Object *o, ULONG flags, long level, gpInput *gpi)
  683. d397 1
  684. d409 1
  685. a409 1
  686. ULONG __saveds RenderERoll(Class *cl, Gadget *g, gpRender *msg)
  687. d417 1
  688. a427 1
  689.         WaitTOF() ;
  690. d437 1
  691. a437 2
  692.                 SetAPen(rp, inst->XPens[GFILL_PEN]) ;
  693.                 RectFill(rp, inst->KLeft-2, inst->KTop-2, inst->KRight+1, inst->KBottom+1) ;
  694. a449 3
  695.                 SetAPen(rp, inst->XPens[GFILL_PEN]) ;
  696.                 Flood(rp, 1, inst->CLeft, inst->CTop) ;
  697.  
  698. d464 1
  699. a464 1
  700. void __saveds RollSize(RollINST *inst, Gadget *g)
  701. d468 1
  702. d479 1
  703. d492 2
  704. a493 1
  705.     inst->angPhase = inst->angMin = c5PID4 ;
  706. a495 1
  707.         inst->angMax = inst->angMin ;
  708. a498 1
  709.         inst->angMax = c7PID4 ;
  710. d504 1
  711. a504 1
  712. void __saveds RollLims(RollINST *inst)
  713. d506 1
  714. d520 1
  715. a520 1
  716.         fix( cos(inst->KStart) * (inst->XRadius - (inst->XUnity * 3.0)) + .5) ;
  717. d523 1
  718. a523 1
  719.         fix( sin(inst->KStart) * (inst->YRadius - (inst->YUnity * 3.0)) + .5) ;
  720. @
  721.